﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    string color = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        //Setting the username on the webpage.
        /*HttpCookie cookie = Request.Cookies.Get("requmanaLogin");
        ctlSignOut.Attributes.
        labelUsername.Text = cookie.Values.Get(1) + " " +cookie.Values.Get(2);*/

        HttpCookie cookie = Request.Cookies.Get("requmanaLogin");

        color = cookie.Values.Get(6);
        if(color == "verde"){
            greenClick(null, null);
        }
        else if(color == "rojo"){
            redClick(null, null);
        }
        else{
            blueClick(null, null);
        }
    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Cookies["requmanaLogin"].Expires = DateTime.Now.AddDays(-1);
        Response.Redirect("FrmLogin.aspx");
    }

    protected void greenClick(object sender, EventArgs e)
    {
        idStyleLink.Href = "../App_Themes/SimplaAdmin/css/style.css";
        setColor("verde");
    }

    protected void redClick(object sender, EventArgs e)
    {
        idStyleLink.Href = "../App_Themes/SimplaAdmin/css/red.css";
        setColor("rojo");
    }

    protected void blueClick(object sender, EventArgs e)
    {
        idStyleLink.Href = "../App_Themes/SimplaAdmin/css/blue.css";
        setColor("azul");
    }

    private void setColor(string nuevoColor)
    {
        HttpCookie cookie = Request.Cookies.Get("requmanaLogin");
        cookie.Values.Set("color", nuevoColor);
        Response.Cookies.Add(cookie);
    }

}
